#ifndef __BST_PRINTER__
#define __BST_PRINTER__

#include <stdio.h>

/**
 * @brief log printers with color
 * 
 */
#define COLOR_BLUE      "\033[34m" //033就是ASCII码27表示Esc
#define COLOR_RED       "\033[31m"
#define COLOR_PURPLE    "\033[35m"
#define COLOR_GREEN     "\033[32m"
#define COLOR_YELLOW    "\033[33m"
#define COLOR_RECOVER   "\033[0m"

enum E_SY_LOG_LEVEL{
    SY_LOGLEVEL_FATAL,
    SY_LOGLEVEL_ERROR,
    SY_LOGLEVEL_WARNING,
    SY_LOGLEVEL_INFO,
    SY_LOGLEVEL_DEBUG,
    SY_LOGLEVEL_MAX,
};

#define SY_LOGLEVEL SY_LOGLEVEL_MAX /**/

#define pr_err(...)  do { \
    if(SY_LOGLEVEL>=SY_LOGLEVEL_ERROR){ \
        fprintf(stderr, COLOR_RED);  \
        fprintf(stderr, __VA_ARGS__);  \
        fprintf(stderr, COLOR_RECOVER); } \
    }while(0)

#define pr_warn(...)  do { \
    if(SY_LOGLEVEL>=SY_LOGLEVEL_WARNING) {\
        fprintf(stdout, COLOR_YELLOW);  \
        fprintf(stdout, __VA_ARGS__);  \
        fprintf(stdout, COLOR_RECOVER); } \
    }while(0)

#define pr_info(...)  do { \
    if(SY_LOGLEVEL>=SY_LOGLEVEL_INFO) {\
        fprintf(stdout, COLOR_GREEN);  \
        fprintf(stdout, __VA_ARGS__);  \
        fprintf(stdout, COLOR_RECOVER); } \
    }while(0)

#define pr_debug(...)  do { \
    if(SY_LOGLEVEL>=SY_LOGLEVEL_DEBUG) {\
        fprintf(stdout, __VA_ARGS__);}  \
    }while(0)



#endif// __BST_PRINTER__

